<template>
	<view class="mine-container" :style="{height: `${windowHeight}px`}">
		<!--顶部个人信息栏-->
		<view class="top_card">
			<img class="top_bg" src="/static/images/bg.png" alt="" />
			<view class="jh_card">
				<view>
					<view>
						<view v-if="!avatar" class="cu-avatar xl round bg-white">
							<view class="iconfont icon-people text-gray icon"></view>
						</view>
						<image v-if="avatar" :src="avatar" class="cu-avatar xl round" mode="widthFix">
						</image>
					</view>
					<view>
						<view v-if="!name && !phone" @click="handleToLogin" class="login-tip">
							点击登录
						</view>
						<view v-if="name||phone" class="margin-left-sm">
							<view class="">
								{{name||phone}}
							</view>
							<view class="margin-tb-sm">
								ID:{{userId}}
							</view>
						</view>
					</view>
				</view>
				<view class="">
					<view class="flex align-center">
						<image src="@/static/images/star.png" class="cu-avatar xl round" style="background-color: #fff;"
							mode="widthFix">
						</image>
						<view class="margin-left-sm">
							<view class="flex align-center margin-tb-sm">
								<view>晶核</view>
								<view class="margin-left-sm">{{ number || 0}}</view>
							</view>
							<view class="flex align-center margin-tb-sm">
								<view>上限</view>
								<view class="margin-left-sm">{{ number || 99999}}</view>
							</view>
					
							
						</view>
					</view>
					<view class="flex justify-end">
						<view class="zhuanzeng_btn" @click="guizePop()">
							规则
						</view>
						<view class="zhuanzeng_btn margin-left-sm" @click="toHistory()">
							记录
						</view>
					</view>
				</view>
				
			</view>
		</view>

		<view class="content-section">
			<view class="mine-actions grid col-3 text-center">
				<view class="action-item" @click="handleShiMing">
					<img src="/static/images/sm.png" alt="" srcset="" />
					<text class="text">实名认证</text>
				</view>
				<view class="action-item" @click="handleShouKuan">
					<img src="/static/images/sm.png" alt="" srcset="" />
					<text class="text">收款账户</text>
				</view>
				<view class="action-item" @click="handleYaoQing">
					<img src="/static/images/yq.png" alt="" srcset="" />
					<text class="text">邀请好友</text>
				</view>
				<view class="action-item" @click="handleCommunity">
					<img src="/static/images/community.png" alt="" srcset="" />
					<text class="text">官方社群</text>
				</view>
				<view class="action-item" @click="handleLogout">
					<img src="/static/images/logout.png" alt="" srcset="" />
					<text class="text">退出登录</text>
				</view>
			</view>

		</view>
		<uni-popup ref="popup" type="center" border-radius="10px 10px 0 0">
			<view class="zhuanzeng_pop">
				<view class="pop_top">
					<view class="pop_title">
						晶核持有规则
					</view>
					<img src="/static/images/close.png" class="pop_close" @click="popClose">
					</img>
				</view>
				<view class="pop_card_info flex">
					
					<view>
						<view class="pop_card_title">
							用户持有晶核有上限，初始上限25晶核<br/>
							当有1个被邀请人持有晶核数大于等于25，上限100晶核<br/>
							当有2个被邀请人持有晶核数大于等于25，上限1000晶核<br/>
							当有3个被邀请人持有晶核数大于等于25，上限5000晶核<br/>
							当有4个被邀请人持有晶核数大于等于25，上限10000晶核<br/>
							当有5个被邀请人持有晶核数大于等于25，上限25000晶核<br/>
							大于等于6个被邀请人持有晶核数大于等于25，上限60000晶核<br/>
						</view>
					</view>
				</view>
			</view>
		</uni-popup>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				userId: this.$store.state.user.id,
				name: this.$store.state.user.name,
				number: this.$store.state.user.number,
				phone: this.$store.state.user.phone
			}
		},
		computed: {
			avatar() {
				return this.$store.state.user.avatar
			},
			windowHeight() {
				return uni.getSystemInfoSync().windowHeight - 50
			}
		},
		methods: {
			guizePop(){
				this.$refs.popup.open()
			},
			toHistory(){
				this.$tab.navigateTo('/pages/mine/jhHistory')
			},
			handleToLogin() {
				this.$tab.reLaunch('/pages/login')
			},
			handleCommunity() {
				this.$tab.navigateTo('/pages/mine/community')
			},
			handleLogout() {
				uni.showModal({
					title: '提示',
					content: '确定要退出登录吗？',
					success: (res) => {
						if (res.confirm) {
							this.$store.dispatch('LogOut').then(() => {
								uni.reLaunch({
									url: '/pages/login'
								});
							});
						}
					}
				})
			},
			handleShiMing() {
				this.$tab.navigateTo('/pages/mine/info/index')
			},
			handleShouKuan() {
				this.$tab.navigateTo('/pages/mine/info/shoukuan')
			},
			handleYaoQing() {
				this.$tab.reLaunch('/pages/mine/info/edit')
			}
		}
	}
</script>

<style lang="scss" scoped>
	page {
		background-color: #f2f3ff;
	}

	.mine-container {
		margin: 0 auto;

		@media screen and (max-width: 1920px) {
			max-width: 500px;
		}

		@media screen and (max-width: 1280px) {
			max-width: 100%;
		}
	}

	.top_card {
		position: relative;
		display: flex;
		justify-content: center;

	}

	.top_bg {
		margin-top: -300rpx;
		width: 100%;

	}

	.jh_card {
		width: 650rpx;
		height: 256rpx;
		background: #FFFFFF;
		box-shadow: 0rpx 22rpx 28rpx -6rpx #E9F3FF;
		border-radius: 40rpx;
		display: flex;
		justify-content: space-between;
		align-items: center;
		position: absolute;
		bottom: -50rpx;
		padding: 40rpx;
	}

	.jh_img {
		width: 90rpx;
		height: 86rpx;
	}

	.mine-container {
		width: 100%;
		height: 100%;


		.header-section {
			padding: 15px 15px 45px 15px;
			background-color: #3c96f3;
			color: white;

			.login-tip {
				font-size: 18px;
				margin-left: 10px;
			}

			.cu-avatar {
				border: 2px solid #eaeaea;

				.icon {
					font-size: 40px;
				}
			}

			.user-info {
				margin-left: 15px;

				.u_title {
					font-size: 18px;
					line-height: 30px;
				}
			}
		}

		.content-section {
			position: relative;
			top: 40px;

			.mine-actions {
				margin: 15px 15px;
				padding: 20px 0px;
				border-radius: 8px;
				background-color: white;

				.action-item {
					img {
						width: 80rpx;
						height: 80rpx;
					}

					.text {
						display: block;
						font-size: 13px;
						margin: 8px 0px;
					}
				}
			}
		}
	}

	.zhuanzeng_btn {
		border: 1rpx solid #000;
		padding: 10rpx 20rpx;
		border-radius: 10rpx;
		background-color: #000;
		color: #fff;
		width: 100rpx;
	}
	
	.zhuanzeng_pop {
		background-color: #fff;
		padding: 40rpx;
		border-radius: 40rpx;
		margin: 0 40rpx;
		width: 670rpx;
		position: relative;
	}
	.pop_top {
		display: flex;
		justify-content: center;
		margin-bottom: 20rpx;
	}
	
	.pop_close {
		width: 30rpx;
		height: 30rpx;
		position: absolute;
		right: 40rpx;
		top: 40rpx;
	}
	
	.pop_title {
		font-size: 36rpx;
		font-weight: 600;
	}
</style>